zm.ready(function() {
////////////delete-response event'/////////////
    zm(".delete-response").click(function() {
        new zm.Boxy({
            title: 'Nhắc nhở',
            content: 'Bạn có chắc xóa phản hồi đã chọn?',
            modal: false,
            okButton: 'Đồng ý',
            cancelButton: 'Hủy bỏ',
            onOk: delResonse
        }).show();

    });
////////////////////////////////////////////////
    function delResonse() {
        var idSurvey = zm("#survey").attr("idsurvey");
        var arrID = new Array();
        zm(".row-table").each(function() {
            if (zm(this).find('input[type="checkbox"]').attr("checked"))
                arrID.push(zm(this).attr("iduser"));
        });
        if (arrID.length <= 0) {
            zm.Boxy.alert("Hãy chọn ít nhất 1 phản hồi", "Thông báo");
            return;
        }
    //    this.close(true);
        ajaxDelResponse(idSurvey, arrID);

    }
/////////////show response detail//////////
    zm(".namecol-res").bind("click", function() {
        raiseClickResponseEvent(zm(this));

    });

///////////////////////////////////////////
///////////select al response detail event////////////////
    zm(".select-all").click(function() {
        var current = zm('input[type="checkbox"]').attr("checked");
        zm(".row-table").each(function() {
            zm(this).find('input[type="checkbox"]').attr("checked", !current);
        });
    });
////////////////////////////////////////////////////////
});
function raiseClickResponseEvent(e) {
     zm(".namecol-res").unbindAll();
    var value = e.parent().parent().find(".data").html();
    var username = e.text();
    e.parent().parent().parent().find(".view-response").removeClass("active");
    e.addClass("active");
    var idUser = e.parent().parent().attr('iduser');
    var x = event.pageX;
    var y = event.pageY;
    var h = zm("#mudium_popup").height();
    var w = zm("#mudium_popup").width();
    var top = y + 16;
    if ((y + w) > window.innerHeight) {
        top = (window.innerHeight / 2) - (h / 2);
    }
    var left = x + 30;
    ajaxGetResponse(username, value, idUser, left, top);
}